import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/route_manager.dart';

class ShareIconSheet {

  static shareIcon(
    String? title, 
    String? description, 
    String? image, 
    String? url,
    {
      bool isShowImg = false,
      Function? wxTap,
      Function? pyqTap,
      Function? qqTap,
      Function? wbTap,
    }
  ) {
    showModalBottomSheet(
      isScrollControlled: true,  
      context: Get.context!,
      backgroundColor: Colors.transparent,
      builder: (BuildContext context) {
        return GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () {
            Get.back();
          },
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              if (isShowImg == true) ...[
                SizedBox(height: 100.w,),
                Expanded(
                  child: Container(
                    padding: EdgeInsets.symmetric(horizontal: 40.w),
                    child: Container(
                      decoration: const BoxDecoration(
                        color: Color(0xfff8faf9),
                        borderRadius: BorderRadius.all(Radius.circular(10)),
                      ),
                      width: double.infinity,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(8.r),
                        child: Image.network(image ?? '', fit: BoxFit.fill,),
                      ),
                    ),
                  ),
                ),
                SizedBox(height: 100.w,),
              ],
              
            
              Container(
                decoration: const BoxDecoration(
                  color: Colors.white,
                ),
                padding: EdgeInsets.symmetric(horizontal: 15.w),
                width: double.infinity,
                child: SafeArea(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      SizedBox(height: 30.w,),
            
                      SizedBox(
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceAround,
                          children: [
                            _shareItemWidget(
                              text: '微信',
                              icon: 'assets/images/share_lt.png',
                              onTap: () {
                                Get.back();
                                wxTap?.call();
                              }
                            ),

                            _shareItemWidget(
                              text: '朋友圈',
                              icon: 'assets/images/share_pyq.png',
                              onTap: () {
                                Get.back();
                                pyqTap?.call();
                              }
                            ),
            
                            _shareItemWidget(
                              text: 'QQ',
                              icon: 'assets/images/share_qq.png',
                              onTap: () {
                                Get.back();
                                qqTap?.call();
                              }
                            ),

                            _shareItemWidget(
                              text: '微博',
                              icon: 'assets/images/share_wb.png',
                              onTap: () {
                                Get.back();
                                wbTap?.call();
                              }
                            ),
                          ],
                        ),
                      ),
            
                      SizedBox(height: 20.w,),
            
                      Container(
                        width: double.infinity,
                        height: 1,
                        color: const Color(0xffEEEEEE),
                      ),
            
            
                      GestureDetector(
                        behavior: HitTestBehavior.translucent,
                        onTap: () {
                          Get.back();
                        },
                        child: Container(
                          alignment: Alignment.center,
                          width: double.infinity,
                          padding: EdgeInsets.only(top: 11.w, bottom: 15.w),
                          child: Text('取消', style: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.bold),),
                        ),
                      )
                    ],
                  ),
                )
              )
            ],
          ),
        );
      },
    );
  }

  static _shareItemWidget({
    Function? onTap,
    String? icon,
    String? text
  }) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        onTap?.call();
      },
      child: SizedBox(
        child: Column(
          children: [
            SizedBox(
              width: 44.w,
              height: 44.w,
              child: Image.asset(icon ?? '', fit: BoxFit.fill,),
            ),
            SizedBox(height: 4.w,),
            SizedBox(
              child: Text(text ?? '', style: TextStyle(fontSize: 11.sp, color: const Color(0xff999999), height: 1.5),),
            )
          ],
        ),
      ),
    );
  }

}